package fr.kyvos.optimization;

/**
 * Class KspItem
 * 
 * @file KspItem.java
 * @author fr.kyvos
 * @date 01 January 2013
 *
 */

public class KspItem {
	private String mName;		// name of the item
	private double mProfit;       // profit of the item
	private double mWeight;       // weight of the item
	private double mRatio;     // ratio between profit and weight

	/**
	 * Class constructor
	 * 
	 * @param pName
	 * @param pProfit
	 * @param pWeight
	 */
	public KspItem(String pName, double pProfit, double pWeight) {
		mName = pName;
		mProfit = pProfit;
		mWeight = pWeight;
		setmRatio((pProfit/pWeight));
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return mName;
	}

	/**
	 * @param pName the name to set
	 */
	public void setName(String pName) {
		mName = pName;
	}

	/**
	 * @return the profit
	 */
	public double getProfit() {
		return mProfit;
	}

	/**
	 * @return the weight
	 */
	public double getWeight() {
		return mWeight;
	}

    /**
     * Display the item
     */
    public String toString() {
    	StringBuilder result = new StringBuilder();
	    String newLine = System.getProperty("line.separator");
	    
	    result.append("- "+mName+" ("+mProfit+"/"+mWeight+")");
	    result.append(newLine);
        
        return result.toString();
    }

	public double getmRatio() {
		return mRatio;
	}

	public void setmRatio(double mRatio) {
		this.mRatio = mRatio;
	}
	
}
